﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
        }
        else
        {
            Response.Redirect("main.aspx");
            Response.End();
            
            vcode.ImageUrl = "vercode.aspx";

            btnLogin.Attributes.Add("OnClick", "javascript:return chk();");

            //设定状态
            if ((this.Session["ecrm_email"] == null) || (this.Session["ecrm_email"].ToString() == ""))
            {
                userstatus1.Text = "你好，请 <a href=\"main.aspx\">登录</a>或 ";
                userstatus2.Text = "<a href=\"./user/user_reg.aspx\">注册</a>";
            }
            else
            {
                //userstatus1.Text = "<a href=\"./user/user_myself.aspx\">自我设置</a>";
                //userstatus2.Text = "<a href=\"./user/user_logout.aspx\">退出</a>";
                this.Response.Redirect("main.aspx");
                this.Response.End();
            }

        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (this.Session["vercode"] == null)
        {
            this.Session["vercode"] = "liuys";
        }
		if (this.Session["vercode"].ToString()==vercode.Text.Trim())
		{
            if (TUser.CheckLogin(email.Text, password.Text, this))
            {
                this.Response.Redirect("main.aspx");
            }
            else
            {
                msg.Text = "你的email和密码不符!";
            }
        }
        else
        {
            vercode.Text = "";
            msg.Text = "验证码错误!";
        }
    }
}
